/*                      - SYSMAC.H -

   Defines system macros to maintain source compatibility
   with different IAR compilers.

   $Revision: 45429 $

   Copyright 1986 - 1999 IAR Systems. All rights reserved.
*/

#ifndef _SYSMAC_H_
#define _SYSMAC_H_

#ifndef _SYSTEM_BUILD
  #pragma system_include
#endif

#if !defined(__IAR_SYSTEMS_ICC__)
  #error The compiler is too old for this library!
#elif __IAR_SYSTEMS_ICC__ < 8
  #error The compiler is too old for this library!
#elif __IAR_SYSTEMS_ICC__ > 8
  #error This library is too old for this compiler!
#endif

#ifndef __CHAR_SIZE__
  #define __CHAR_SIZE__ sizeof(char)
#endif

#ifndef __SHORT_SIZE__
  #define __SHORT_SIZE__ sizeof(short)
#endif

#ifndef __INT_SIZE__
  #define __INT_SIZE__ sizeof(int)
#endif

#ifndef __LONG_SIZE__
  #define __LONG_SIZE__ sizeof(long)
#endif

#ifndef __FLOAT_SIZE__
  #define __FLOAT_SIZE__ sizeof(float)
#endif

#ifndef __DOUBLE_SIZE__
  #define __DOUBLE_SIZE__ sizeof(double)
#endif

#ifndef __LONG_DOUBLE_SIZE__
  #define __LONG_DOUBLE_SIZE__ sizeof(long double)
#endif

#ifndef __SIZE_T_TYPE__
  #if sizeof((char*)0 - (char*)0) <= sizeof(int)
    #define __SIZE_T_TYPE__ unsigned int
  #else
    #define __SIZE_T_TYPE__ unsigned long
  #endif
#endif

#ifndef __PTRDIFF_T_TYPE__
  #if sizeof((char*)0 - (char*)0) <= sizeof(int)
    #define __PTRDIFF_T_TYPE__ signed int
  #else
    #define __PTRDIFF_T_TYPE__ signed long
  #endif
#endif

#ifndef __JMP_BUF_ELEMENT_TYPE__
  #ifndef __JMP_BUF_NUM_ELEMENTS__
    #define __JMP_BUF_ELEMENT_TYPE__  char
    #ifndef __JMP_BUF__
      #define __JMP_BUF_NUM_ELEMENTS__  8
    #else
      #define __JMP_BUF_NUM_ELEMENTS__  __JMP_BUF__
    #endif
  #endif
#endif


#define __INTRINSIC __intrinsic
#define __NORETURN __noreturn

/* Macro for frmwri and frmrd */
#define VAPTR(T) (va_arg(ap, T *))

/* Typedefs put here to appear only once */
typedef __SIZE_T_TYPE__    size_t;
typedef __PTRDIFF_T_TYPE__ ptrdiff_t;

#define _HAS_PRAGMA_PRINTF_ARGS

/* A definiton for a function of what effects it has.
   NS  = no_state, i.e. it uses no internal or external state. It may write
         to errno though
   NE  = no_state, no_errno,  i.e. it uses no internal or external state,
         not even writing to errno. 
   NRx = no_read(x), i.e. it doesn't read through pointer parameter x.
   NWx = no_write(x), i.e. it doesn't write through pointer parameter x.
*/

#define __EFF_NS       _Pragma("function_effects = no_state")
#define __EFF_NE       _Pragma("function_effects = no_state, no_errno")
#define __EFF_NENR1NW2R1 _Pragma("function_effects = no_state, no_errno, no_read(1), no_write(2), returns 1")
#define __EFF_NENR1R1 _Pragma("function_effects = no_state, no_errno, no_read(1), returns 1")
#define __EFF_NENR2 _Pragma("function_effects = no_state, no_errno, no_read(2)")
#define __EFF_NENW1 _Pragma("function_effects = no_state, no_errno, no_write(1)")
#define __EFF_NENW1NW2 _Pragma("function_effects = no_state, no_errno, no_write(1,2)")
#define __EFF_NENW2R1 _Pragma("function_effects = no_state, no_errno, no_write(2), returns 1")
#define __EFF_NR1      _Pragma("function_effects = no_read(1)")
#define __EFF_NR1NW2   _Pragma("function_effects = no_read(1), no_write(2)")
#define __EFF_NW1      _Pragma("function_effects = no_write(1)")
#define __EFF_NW2      _Pragma("function_effects = no_write(2)")
#define __EFF_NW1NR2   _Pragma("function_effects = no_write(1), no_read(2)")
#define __EFF_NW1NW2   _Pragma("function_effects = no_write(1,2)")


#endif /* _SYSMAC_H_ */
